from db import *
from util import *
import json
import copy
from config import *









def get_comment_dict(d):
    pass

dd={"name_": "用户姓名", "phone_": "手机号", "login": "18100000000", "company_name_": "公司名称", "id_": "商务经理用户id", "register_state": "已通过", "login_": "登录名", "company_name": "广东深华消防广州分公司", "name": "王涛", "register_state_": "注册状态(待认证,待提交,审核中,已通过,被退回,已失效)", "id": 1, "phone": "18100000000"}

remain_data_dict(dd)

print(dd)
def gen_response_data(d):
    r={}

    a=copy.deepcopy(d)




    return r

gen_response_data(dd)

d={'id':1,'name':'王涛','register_state':'已认证','company_name':'广东深华消防广州分公司','phone':'18100000000','login':'18100000000'}

#
# ('wait',u'待认证'),
# ('waiting',u'待提交'),
# ('under_review',u'审核中'),
# ('adopt',u'已通过'),
# ('return',u'被退回'),
# ('Invalid',u'已失效')


gen_comment_key(d)
print(d2j(d))

d={
    "name":'c',"company_name":'v',
    "doc":{"name_":'名称',"company_name_":'公司名称'}
}



{"name_": "用户姓名", "phone_": "手机号", "login": "18100000000", "company_name_": "公司名称", "id_": "商务经理用户id", "register_state": "已认证", "login_": "登录名", "company_name": "广东深华消防广州分公司", "name": "王涛", "register_state_": "注册状态(待认证,待提交,审核中,已通过,被退回,已失效)", "id": 1, "phone": "18100000000"}


doc_list=[
    ['登入','POST','login',{"password_": "密码", "login_": "登录名", "login": "18100000000", "password": "18300023454"},{"name_": "用户姓名", "phone_": "手机号", "login": "18100000000", "company_name_": "公司名称", "id_": "商务经理用户id", "register_state": "已通过", "login_": "登录名", "company_name": "广东深华消防广州分公司", "name": "王涛", "register_state_": "注册状态(待认证,待提交,审核中,已通过,被退回,已失效)", "id": 1, "phone": "18100000000"},''],

]


doc_db_list=[doc[0:3]+[d2j(doc[3])]+[d2j(doc[4])]+[doc[5]] for doc in doc_list]


with DBConnection(DBPOOL) as conn:
    cr=conn.cursor()
    cr.execute("DELETE FROM t_doc")
    cr.insert_many(doc_db_list,'doc',['name','method','url','request_json','response_json','remark'])